<?php
namespace app\common\logic;

use think\facade\Db;

class DataLogic{
    public static function getDataList($query,array $where,$order,$field,$limit=10,$page=1,$append)
    {
        $total=$query->where($where)->count();
        $list=$query->where($where)
            ->field($field)->order($order)
            ->limit($limit)->page($page)
//            ->fetchSql()
//            ->select();
//        dd($list);
            ->select()
            ->append($append)
            ->toArray();
        if(isset($list[0]['write_off'])){
            foreach($list as $k=>$v){
                switch ($list[$k]['write_off']){
                    case 1:
                        $list[$k]['write_off'] = '已核销';
                        break;
                    case 2:
                        $list[$k]['write_off'] = '未核销';
                        break;
                    case 3:
                        $list[$k]['write_off'] = '不需要核销';
                        break;
                }
            }
        }
        return ['total'=>$total,'list'=>$list];
    }
}
